//
//  CommodityWarehouseTableViewCell.m
//  BusinessApp
//
//  Created by CccDaxIN on 2016/10/27.
//  Copyright © 2016年 macox. All rights reserved.
//

#import "CommodityWarehouseTableViewCell.h"

@implementation CommodityWarehouseTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    [_CommodityWChoice.layer setMasksToBounds:YES];
    _CommodityWChoice.layer.cornerRadius = 5;

    // Initialization code
}
- (void)setModel:(ReleaseCommoditySubModel *)model{
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *imageStr = [NSString stringWithFormat:@"%@%@",ReleaseORDebug,model.ImagePath];
        NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:imageStr]];        dispatch_async(dispatch_get_main_queue(), ^{
            _CommodityWImage.image = [UIImage imageWithData:data];
            
        });
    });
    
    _CommodityWTitle.text = model.ProductName;
    /**价格
     */
    NSString *stringPrice = [NSString stringWithFormat:@"%.2f元",model.Price];
    _CommodityWPrice.text = stringPrice;
    _Id = model.Id;
}

#pragma mark -- 选择商品
- (IBAction)choiceButtonAction:(UIButton *)sender {
    
    /*代理
     **/
    if ([[NNSingleton sharedSingleton].releasePosition isEqualToString:@"搜索"]) {
        [self.delegate searchButtonActionDelegate:[NSString stringWithFormat:@"%d",_Id]];
        
    }else{
        [self.delegate choiceButtonActionDelegate:[NSString stringWithFormat:@"%d",_Id]];
    }
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
